﻿@using MvcApplication.Entity;
@model Post
@{
    ViewBag.Title = Model.ID == 0 ? "新建" : "编辑";
}
<style>
    .cover {
        max-width: 360px;
        max-height: 200px;
    }
</style>
@helper getStatus(PostStatus status)
{
    if (status == Model.Status)
    {
    @Html.Raw("am-active");
    }
}
<div class="am-cf am-padding">
    <div class="am-fl am-cf">
        <strong class="am-text-primary am-text-lg">文章</strong> /
        <small>@ViewBag.Title</small>
    </div>
</div>
@helper getAfterSaveAction(string flag)
{
    if (Request.QueryString["next_action"] == flag)
    {
    @Html.Raw("selected");
    }
}
<div class="am-g">
    <div class="am-u-sm-8">
        <form class="am-form">
            <input type="hidden" value="@Model.ArticleID" name="ArticleID" />
            <input type="hidden" value="@Model.ID" name="ID" />
            <input type="hidden" value="@PostClassify.单页页面" name="classify" />
            <div class="am-g am-margin-top">
                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                    文章标题
                </div>
                <div class="am-u-sm-8 am-u-md-10">
                    <input style="width:101%" type="text" class="am-input-sm" name="title" value="@Model.Title" placeholder="必填，不可重复">
                </div>
            </div>

            <div class="am-g am-margin-top-sm">
                <div class="am-u-sm-12 am-u-md-2 am-text-right admin-form-text">
                    文章内容
                </div>
                <div class="am-u-sm-12 am-u-md-10">
                    <textarea id="detail" name="detail" rows="10" style="width: 100%; height: 535px;" placeholder="">@Html.Raw(Model.Detail)</textarea>
                </div>
            </div>

            <div class="am-g am-margin-top-sm">
                <div class="am-u-sm-12 am-u-md-2 am-text-right admin-form-text">
                    &nbsp;
                </div>
                <div class="am-u-sm-12 am-u-md-10">
                    <button type="button" onclick="savePost(this)" class="am-btn am-btn-primary ">提交保存</button>
                    <select data-am-selected name="next_action" id="next_action">
                        <option value="1" @getAfterSaveAction("1")>保存后继续新建</option>
                        <option value="2" @getAfterSaveAction("2")>保存后继续编辑</option>
                        <option value="3" @getAfterSaveAction("3")>保存后返回列表</option>
                    </select>

                </div>
            </div>
        </form>
    </div>
    <div class="am-u-sm-4">
        <div style="margin-top: 20px;"></div>
        <div class="am-panel am-panel-default">
            <div class="am-panel-hd am-cf" data-am-collapse="{target: '#collapse-panel-2'}">封面设置<span class="am-icon-chevron-down am-fr"></span></div>
            <div class="am-panel-bd am-collapse am-in" id="collapse-panel-2">
                <form class="am-form">
                    @if (!string.IsNullOrEmpty(Model.FirstPicture))
                    { 
                        <input type="hidden" id="FirstPicture" value="" name="FirstPicture" />
                    }
                    else
                    {
                        <input type="hidden" id="FirstPicture" value="@Model.FirstPicture" name="FirstPicture"/>
                    }

                    <div style="height: 200px; border: 1px #eee dashed;" id="coverImageEl" class="column">
                        @if (!string.IsNullOrEmpty(Model.FirstPicture))
                        {
                            <img class="cover" src="/image?path=@Model.FirstPicture" />       
                        }
                    </div>
                    <div class="am-form-group " style="margin-top: 5px; height: 20px;">
                        <div class="am-u-sm-5 am-form-file" style="padding: 0;">
                            <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                <i class="am-icon-cloud-upload"></i>&nbsp;选择封面图片
                            </button>
                            <input id="coverEl" value="选择封面" type="file" onchange="uploadFile(this)" />
                        </div>
                        <div class="am-u-sm-7" style="padding: 0;">
                            <a href="javascript:;"
                                onclick="editCoverPicture()"
                                class="am-btn am-btn-danger am-btn-sm">
                                <i class="am-icon-edit"></i>&nbsp;编辑封面
                            </a>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div class="am-panel am-panel-default">
            <div class="am-panel-hd am-cf" data-am-collapse="{target: '#collapse-panel-3'}">SEO设置<span class="am-icon-chevron-down am-fr"></span></div>
            <div class="am-panel-bd am-collapse am-in" id="collapse-panel-3">
                <form class="am-form">
                    <div class="am-g am-margin-top-sm">
                        <div class="am-u-sm-12 am-u-md-12 am-u-end">
                            <input type="text" class="am-input-sm" placeholder="SEO标题">
                        </div>
                    </div>

                    <div class="am-g am-margin-top-sm">
                        <div class="am-u-sm-12 am-u-md-12 am-u-end">
                            <input type="text" class="am-input-sm" placeholder="SEO关键字，多个用半角都好隔开" />
                        </div>
                    </div>

                    <div class="am-g am-margin-top-sm">
                        <div class="am-u-sm-12 am-u-md-12 am-u-end">
                            <textarea rows="4" placeholder="SEO 描述"></textarea>
                        </div>
                    </div>
                </form>
            </div>
        </div>

    </div>

</div>


@Scripts.Render("~/Content/kindeditor/kindeditor-all-min.js")
@Scripts.Render("~/Content/kindeditor/lang/zh_CN.js")
@Scripts.Render("~/Content/js/common/file-upload.js")


<script>
    KindEditor.ready(function (K) {
        window.editor = K.create('#detail', {
            width: '101%',
            height: '425px',
            uploadJson: '/image/index',
            items: [
                    'fontname', 'fontsize', 'wordpaste', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                    'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                    'insertunorderedlist', '|', 'image', 'multiimage', 'link', 'preview'
            ]
        });
    });
</script>
@Scripts.Render("~/Content/js/single-page/edit.js")
